<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>鸿博租房物业有限公司</title>
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <link rel="stylesheet" href="/layui/css/layui.css">
    <script src="/layui/layui.js"></script>
    <script src="/js/jquery-1.8.3.js"></script>
</head>
<body class="layui-layout-body"><!-- background="/imgs/123.jpg" -->

<form class="layui-form" onsubmit="return proregion()">
  <input type="hidden" name="_token" value="{{ csrf_token() }}" id="_token">

  <div class="layui-form-item">
    <label class="layui-form-label">物业名称框</label>
    <div class="layui-input-inline">
      <input type="pro_name" name="pro_name" id="pro_name" required lay-verify="required" placeholder="请输入物业用户名" autocomplete="off" class="layui-input" onblur="name_z()">
      <span id="name_s"></span>
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">密码框</label>
    <div class="layui-input-inline">
      <input type="password" name="pro_pwd" id="pro_pwd" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input" onblur="pwd_z()">
      <span id="pwd_s"></span>
    </div>
  </div>


  <div class="layui-inline">
      <label class="layui-form-label">物业邮箱</label>
      <div class="layui-input-inline">
        <input type="email" name="pro_email" id="pro_email" lay-verify="pro_email" autocomplete="off" class="layui-input" placeholder="请输入邮箱" onblur="email_z()">
        <span id="email_s"></span>
      </div>
    </div>
  </div>
<br><br>
 <div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label">手机号</label>
      <div class="layui-input-inline">
        <input type="pro_tel" name="pro_tel" id="pro_tel" lay-verify="required|pro_tel" autocomplete="off" class="layui-input" placeholder="请输入手机号" onblur="tel_z()">
        <span id="tel_s"></span>
      </div>
    </div>

     <div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label">物业公司地址</label>
      <div class="layui-input-inline">
        <input type="pro_address" name="pro_address" id="pro_address" lay-verify="required|pro_address" autocomplete="off" class="layui-input" placeholder="请输入公司地址" onblur="address_z()">
        <span id="address_s"></span>
      </div>
    </div>

  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="formDemo" onclick="proregion()">注册</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
      <a href="{{url('/home/prologin')}}">已有账号请登录</a>
    </div>
  </div>



</form>

<script>
function address_z(){
  var name_z = /[\u4e00-\u9fa5]{6,30}/;
  var pro_address = $('#pro_address').val();
  if(pro_address.length == 0){
    $('#address_s').html("<font color='red'>地址不能为空</font>");
    return false;
  }else{
    if(name_z.test(pro_address)){
      $('#address_s').html("<font color='green'>地址格式正确</font>");
      return true;
    }else{
      $('#address_s').html("<font color='red'>请输入6到30位的公司地址</font>");
      return false;
    }
  }
}

function tel_z(){
  var tel_z = /^1[34578]\d{9}$/;
  var pro_tel = $('#pro_tel').val();
  if(pro_tel.length == 0){
    $('#tel_s').html("<font color='red'>手机号不能为空</font>");
    return false;
  }else{
    if(tel_z.test(pro_tel)){
      $('#tel_s').html("<font color='green'>手机号格式正确</font>");
      return true;
    }else{
      $('#tel_s').html("<font color='red'>手机号不能多余11位和少于11位</font>");
      return false;
    }
  }
}   

function email_z(){
  var email_z = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
  var pro_email = $('#pro_email').val();
  if(pro_email.length == 0){
    $('#email_s').html("<font color='red'>邮箱名不能为空</font>");
    return false;
  }else{
    if(email_z.test(pro_email)){
      $('#email_s').html("<font color='green'>邮箱格式正确</font>");
      return true;
    }else{
      $('#email_s').html("<font color='red'>请输入正确的邮箱后面加上@qq.com</font>");
      return false;
    }
  }
  

}

function pwd_z(){
   var pwd_z = /^.*(?=.{6,})(?=.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*? ]).*$/;
   var pro_pwd = $('#pro_pwd').val();
   if(pro_pwd.length == 0){
    $('#pwd_s').html("<font color='red'>密码名不能为空</font>");
    return false;
   }else{
     if(pwd_z.test(pro_pwd)){
        $('#pwd_s').html("<font color='green'>密码格式正确</font>");
        return true;
     }else{
        $('#pwd_s').html("<font color='red'>密码最少6位，包括至少1个大写字母，1个小写字母，1个数字，1个特殊字符</font>");
        return false;
     }
   }
}

function name_z(){
  var name_z = /[\u4e00-\u9fa5]{6,12}/;
  var pro_name = $('#pro_name').val();
  if(pro_name.length == 0){
    $('#name_s').html("<font color='red'>用户名不能为空</font>");
    return false;
  }else{
    if(name_z.test(pro_name)){
      $('#name_s').html("<font color='green'>用户名格式正确</font>");
      return true;
    }else{
      $('#name_s').html("<font color='red'>请输入6到12位的公司名称</font>");
      return false;
    }
  }
}


function proregion(){
    if(name_z() == false || pwd_z() == false || email_z() == false || tel_z() == false || address_z() == false){
      return false;
    }
    var _token  = $('#_token').val();
    var pro_name  = $('#pro_name').val();
    var pro_pwd   = $('#pro_pwd').val();
    var pro_email = $('#pro_email').val();
    var pro_tel   = $('#pro_tel').val();
    var pro_address  = $('#pro_address').val();


    var data = new FormData();

    data.append('pro_name',pro_name);
    data.append('pro_pwd',pro_pwd);
    data.append('pro_email',pro_email);
    data.append('pro_tel',pro_tel);
    data.append('pro_address',pro_address);
    data.append('_token',_token);

   $.ajax({
          type: "POST",
          url: "{{url('/home/proregion')}}",
          data: data,
          cache: false,
          processData: false,
          contentType: false,
          success: function(msg){
              if(msg ==1){
                alert('公司注册成功')
                window.location.href="{{url('/home/index')}}";
              }else{
                alert(注册失败)
                window.location.href="{{url('/home/proregister')}}";
              }
          }
      });

}
//Demo
layui.use('form', function(){
  var form = layui.form;
  
  //监听提交
  form.on('submit(formDemo)', function(data){
    //layer.msg(JSON.stringify(data.field));
    return false;
  });
});
</script>

</body>
</html>